package com.zzs.server.controller;

import com.zzs.common.core.response.Result;
import com.zzs.common.minio.entity.File;
import com.zzs.server.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author zzs
 * @date 2025/03/21
 */
@RestController
@RequestMapping("/server/file")
public class FileController {
    @Autowired
    private FileService fileService;

    @PostMapping("/image")
    public Result<File> uploadImage(@RequestParam("file") MultipartFile file) {
        File imageFile = fileService.uploadImage(file);
        return Result.success(imageFile);
    }

    @DeleteMapping
    public Result<Void> removeFiles(@RequestBody List<String> fileNameList) {
        fileService.removeFiles(fileNameList);
        return Result.success();
    }
}
